package com.rx.mine.service;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import com.rx.core.base.RxBaseData;
import com.rx.core.enm.HANDLER_TYPE;
import com.rx.core.enm.RESULT_CODE;
import com.rx.core.enm.RX_STATUS;
import com.rx.core.service.RxBaseAbstractService;
import com.rx.core.service.StandardService;
import com.rx.core.util.EmptyChecker;
import com.rx.core.util.RxUtil;
import com.rx.mine.bean.WxConfiguration;
import com.rx.mine.dao.MineBattleInfoMapper;
import com.rx.mine.vo.*;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.PostConstruct;
import java.util.*;
import java.util.stream.Collectors;

@Slf4j
@Service
public class MineService extends RxBaseAbstractService {

    private static final String WX = "weixin";
    private static final Integer FAIL = 0;
    private static final Integer SUCCESS = 1;

    @Autowired
    WxConfiguration wxConfiguration;

    @Autowired
    StandardService standardService;

    @Autowired
    CacheService cacheService;

    @PostConstruct
    public void init() throws InterruptedException {
        // 启动运行。


    }

    private MineAccuScores getMineAccuScores(String openId){

        try {
            MineAccuScores mineAccuScores = (MineAccuScores) MineAccuScores.create(MineAccuScores.class, HANDLER_TYPE.SINGLE_LIST);
            mineAccuScores.setOtherBid(openId);
            mineAccuScores.getHandlerController().onlyDefault();
            Object object = standardService.searchList(mineAccuScores);

            List<MineAccuScores> list = RxUtil.result(object);
            if(EmptyChecker.notEmpty(list)){
                return list.get(0);
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }

        return null;
    }

    private MineAccuScores saveMineAccuScores(AppLoginVo appLoginVo) throws IllegalAccessException, InstantiationException {

        MineAccuScores mineAccuScores = (MineAccuScores) MineAccuScores.create(MineAccuScores.class, HANDLER_TYPE.SINGLE_INSERT);
        mineAccuScores.setOtherBid(appLoginVo.getOpenId());
        mineAccuScores.setNickName(appLoginVo.getNickName());
        mineAccuScores.setPoint(0);
        mineAccuScores.setLevel(0);
        mineAccuScores.setFailCount(0);
        mineAccuScores.setSuccessCount(0);
        mineAccuScores.setSignInRecord(0);
        mineAccuScores.setMaxDifficult(10000);
        mineAccuScores.setStatus(RX_STATUS.NORMAL.getCode());
        mineAccuScores.getHandlerController().onlyDefault();
        Object object = standardService.insert(mineAccuScores);
        return mineAccuScores;
    }



    private Object wxLogin(AppLoginVo appLoginVo){
        WxMaService wxMaService = ((WxMaService) wxConfiguration.wxService(wxConfiguration.wxMaConfig()));
        try {
            WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(appLoginVo.getCode());

            // 根据session 查询是否用户是否注册，
            MineAccuScores mineAccuScores = getMineAccuScores(appLoginVo.getLoginType() + session.getOpenid());
            if(EmptyChecker.notEmpty(mineAccuScores)) {
                RxUtil.CheckUtil.check(!RX_STATUS.NORMAL.getCode().equalsIgnoreCase(mineAccuScores.getStatus()), RESULT_CODE.MESSAGE, "账号异常");

                //生成token 给前端。
                String uuid = RxUtil.getGUID();
                appLoginVo.setToken(uuid);
                appLoginVo.setPoint(mineAccuScores.getPoint());
                appLoginVo.setSignInRecord(mineAccuScores.getSignInRecord());
                appLoginVo.setLastSignDate(mineAccuScores.getLastSignDate());
                appLoginVo.setFailCount(mineAccuScores.getFailCount());
                appLoginVo.setSuccessCount(mineAccuScores.getSuccessCount());
                appLoginVo.setOpenId(session.getOpenid());
                appLoginVo.setLevel(mineAccuScores.getLevel());
                appLoginVo.setBid(mineAccuScores.getBid());
                appLoginVo.setVer(mineAccuScores.getVer());
                appLoginVo.setMaxDifficult(mineAccuScores.getMaxDifficult());

                if(appLoginVo.getNickName().indexOf("微信用户") == 0){
                    appLoginVo.setNickName(mineAccuScores.getNickName());
                }


                if(!mineAccuScores.getNickName().equalsIgnoreCase(appLoginVo.getNickName())){
                    mineAccuScores.setNickName(appLoginVo.getNickName());
                    mineAccuScores.resetHandlerType(HANDLER_TYPE.SINGLE_UPDATE);
                    mineAccuScores.getHandlerController().onlyDefault();
                    standardService.update(mineAccuScores);
                    appLoginVo.setVer(appLoginVo.getVer()+1);
                }

                cacheService.putData(uuid,appLoginVo);
                cacheService.putData(session.getOpenid(),uuid);
            }else {
                // 首次登录
                appLoginVo.setOpenId(appLoginVo.getLoginType() + session.getOpenid());
                mineAccuScores = saveMineAccuScores(appLoginVo);
                String uuid = RxUtil.getGUID();
                appLoginVo.setToken(uuid);
                appLoginVo.setPoint(0);
                appLoginVo.setSignInRecord(0);
                appLoginVo.setFailCount(0);
                appLoginVo.setSuccessCount(0);
                appLoginVo.setMaxDifficult(10000);
                appLoginVo.setOpenId(session.getOpenid());
                appLoginVo.setLevel(0);
                appLoginVo.setBid(mineAccuScores.getBid());
                appLoginVo.setVer(mineAccuScores.getVer());
                cacheService.putData(uuid,appLoginVo);
                cacheService.putData(session.getOpenid(),uuid);
            }

            return appLoginVo;

        } catch (WxErrorException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
        return null;
    }




    @Transactional
    public Object appLogin(AppLoginVo appLoginVo) throws IllegalAccessException, InstantiationException {

        RxUtil.CheckUtil.check(appLoginVo.getLoginType(), RESULT_CODE.MESSAGE,"登录类型为空");

        RxUtil.CheckUtil.condition(EmptyChecker.isEmpty(appLoginVo.getCode())&&EmptyChecker.isEmpty(appLoginVo.getToken()), RESULT_CODE.MESSAGE,"登录Code为空");


        if(EmptyChecker.notEmpty(appLoginVo.getToken())||EmptyChecker.notEmpty(appLoginVo.getOpenId())){

            // 判断是否登录。TODO:以后换分布式缓存
            String token = appLoginVo.getToken();
            if(EmptyChecker.isEmpty(token)){
                token = (String)cacheService.getData(appLoginVo.getOpenId());
                if(EmptyChecker.isEmpty(token)){
                    RxUtil.CheckUtil.throwOut(RESULT_CODE.LOGIN_ERR,"未登录");
                }
            }

            AppLoginVo appLogin = (AppLoginVo)cacheService.getData(token);
            if(EmptyChecker.isEmpty(appLogin)){
                RxUtil.CheckUtil.throwOut(RESULT_CODE.LOGIN_ERR,"未登录");
            }

            if(appLoginVo.getNickName().indexOf("微信用户") == 0){
                appLoginVo.setNickName(appLogin.getNickName());
            }

            if(!appLogin.getNickName().equalsIgnoreCase(appLoginVo.getNickName())){
                MineAccuScores mineAccuScores = (MineAccuScores)MineAccuScores.create(MineAccuScores.class,HANDLER_TYPE.SINGLE_UPDATE);
                mineAccuScores.setNickName(appLoginVo.getNickName());
                mineAccuScores.resetHandlerType(HANDLER_TYPE.SINGLE_UPDATE);
                mineAccuScores.getHandlerController().onlyDefault();
                mineAccuScores.setBid(appLogin.getBid());
                mineAccuScores.setVer(appLogin.getVer());
                standardService.update(mineAccuScores);


                appLogin.setVer(appLogin.getVer()+1);
                appLogin.setNickName(appLoginVo.getNickName());
                cacheService.putData(token,appLogin);

            }
            return appLogin;

        }

        if(WX.equalsIgnoreCase(appLoginVo.getLoginType())){
            return wxLogin(appLoginVo);
        }
        RxUtil.CheckUtil.throwOut(RESULT_CODE.FAIL,"登录失败");
        return "";

    }

    private Integer getScoreBySign(int signFlg){
        signFlg++;
        signFlg = signFlg - (signFlg & (signFlg - 1));

        switch(signFlg){
            case 0:
            case 1:
                return 0;
            case 2:
                return 1;
            case 4:
                return 2;
            case 8:
                return 3;
            case 16:
                return 4;
            case 32:
                return 5;

        }
        return 5;
    }
    public static int differentDaysByMillisecond(Date date1,Date date2){

        if(EmptyChecker.isEmpty(date1)){
            //10天代表不连续
            return 10;
        }

        Calendar calendarNow = Calendar.getInstance();
        calendarNow.setTime(date1);

        Calendar calendar= Calendar.getInstance();
        calendar.set(calendarNow.get(Calendar.YEAR),
                calendarNow.get(Calendar.MONTH),
                calendarNow.get(Calendar.DATE),0,0,0);
        //年月日 也可以具体到时分秒如calendar.set(2015, 10, 12,11,32,52);
        Date tmp=calendar.getTime();//date就是你需要的时间


        int days = (int) ((date2.getTime() - tmp.getTime()) / (1000*3600*24));
        return days;
    }
    @Transactional
    public Object consume(AppLoginVo appLoginVo) throws IllegalAccessException, InstantiationException {
        RxUtil.CheckUtil.check(appLoginVo.getToken(), RESULT_CODE.LOGIN_ERR, "未登录");
        RxUtil.CheckUtil.check(appLoginVo.getPoint(), RESULT_CODE.MESSAGE, "积分");
        // 判断是否登录。TODO:以后换分布式缓存
        AppLoginVo appLogin = (AppLoginVo) cacheService.getData(appLoginVo.getToken());
        if (EmptyChecker.isEmpty(appLogin)) {
            RxUtil.CheckUtil.throwOut(RESULT_CODE.LOGIN_ERR, "未登录");
        }

        if(appLogin.getPoint() < appLoginVo.getPoint()){
            RxUtil.CheckUtil.throwOut(RESULT_CODE.MESSAGE, "积分不够");
        }
        MineAccuScores mineAccuScores = (MineAccuScores) MineAccuScores.create(MineAccuScores.class, HANDLER_TYPE.SINGLE_UPDATE);
        mineAccuScores.setBid(appLogin.getBid());
        mineAccuScores.setVer(appLogin.getVer());
        mineAccuScores.setPoint(appLogin.getPoint()== null?0:appLogin.getPoint() - appLoginVo.getPoint());

        Object object = standardService.update(mineAccuScores);

        appLogin.setVer(appLogin.getVer() + 1);
        appLogin.setPoint(mineAccuScores.getPoint());
        cacheService.putData(appLogin.getToken(),appLogin);
        return mineAccuScores;

    }
    @Transactional
    public Object sign(AppLoginVo appLoginVo) throws IllegalAccessException, InstantiationException {
        RxUtil.CheckUtil.check(appLoginVo.getToken(), RESULT_CODE.MESSAGE,"未登录");
        // 判断是否登录。TODO:以后换分布式缓存
        AppLoginVo appLogin = (AppLoginVo)cacheService.getData(appLoginVo.getToken());
        if(EmptyChecker.isEmpty(appLogin)){
            RxUtil.CheckUtil.throwOut(RESULT_CODE.LOGIN_ERR,"未登录");
        }

        MineAccuScores mineAccuScores = (MineAccuScores) MineAccuScores.create(MineAccuScores.class, HANDLER_TYPE.SINGLE_UPDATE);
        mineAccuScores.setBid(appLogin.getBid());
        mineAccuScores.setVer(appLogin.getVer());

        int signFlg = appLogin.getSignInRecord() == null?0:appLogin.getSignInRecord();

        int diff = differentDaysByMillisecond(appLogin.getLastSignDate(),appLogin.getCurrentDate());

        signFlg = signFlg << diff;
        signFlg++;
        signFlg= signFlg&8191; // 去掉高位。


        mineAccuScores.setSignInRecord(signFlg);
        mineAccuScores.setLastSignDate(new Date());
        mineAccuScores.setPoint(appLogin.getPoint()== null?0:appLogin.getPoint() + getScoreBySign(signFlg));
        mineAccuScores.setLevel(appLogin.getLevel());

        mineAccuScores.getHandlerController().onlyDefault();
        Object object = standardService.update(mineAccuScores);

        appLogin.setVer(appLogin.getVer() + 1);
        appLogin.setSignInRecord(signFlg);
        appLogin.setLastSignDate(new Date());
        appLogin.setPoint(mineAccuScores.getPoint());
        cacheService.putData(appLogin.getToken(),appLogin);
        return mineAccuScores;

    }

    @Transactional
    public Object record(AppRecordVo appLoginVo) throws IllegalAccessException, InstantiationException {

        RxUtil.CheckUtil.check(appLoginVo.getToken(), RESULT_CODE.MESSAGE,"未登录");


        if(EmptyChecker.isEmpty(appLoginVo.getList())){
            RxUtil.CheckUtil.throwOut(RESULT_CODE.MESSAGE,"没有题");
        }

        int failCount = 0;
        int successCount = 0;
        for (SubjectItem subjectItem : appLoginVo.getList()) {
            if(SUCCESS.equals(subjectItem.getResult())){
                successCount++;
            }else{
                failCount++;
            }
        }
        // 判断是否登录。TODO:以后换分布式缓存
        AppLoginVo appLogin = (AppLoginVo)cacheService.getData(appLoginVo.getToken());
        if(EmptyChecker.isEmpty(appLogin)){
            RxUtil.CheckUtil.throwOut(RESULT_CODE.LOGIN_ERR,"未登录");
        }

        MineAccuScores mineAccuScores = (MineAccuScores) MineAccuScores.create(MineAccuScores.class, HANDLER_TYPE.SINGLE_UPDATE);
        mineAccuScores.setBid(appLogin.getBid());
        mineAccuScores.setVer(appLogin.getVer());
        mineAccuScores.setFailCount(failCount + (appLogin.getFailCount()==null?0:appLogin.getFailCount()));
        mineAccuScores.setSuccessCount(successCount + (appLogin.getSuccessCount()==null?0:appLogin.getSuccessCount()));


        if(appLogin.getLevel() == 0){ // 小白
            if(appLoginVo.getList().size() == successCount){
                mineAccuScores.setLevel(1);
                appLogin.setLevel(1);
            }
        }



        MineExamSubject subject = (MineExamSubject) MineExamSubject.create(MineExamSubject.class, HANDLER_TYPE.SINGLE_LIST);
        subject.getHandlerController().onlyDefault();
        Map<String,Object> map = new HashMap<>();
        map.put("inCode",appLoginVo.getList().stream().map(e->e.getCode()).collect(Collectors.toList()));
        subject.setCondition(map);

        List<RxBaseData> list = RxUtil.result(standardService.searchList(subject));
        if(EmptyChecker.isEmpty(list)){
            RxUtil.CheckUtil.throwOut(RESULT_CODE.MESSAGE,"题目查询失败");
        }

        Map<String,List<SubjectItem>> mapReuslt = appLoginVo.getList().stream().collect(Collectors.groupingBy(e->e.getCode()));

        Integer minRate = 10000;
        for (RxBaseData rxBaseData : list) {
            MineExamSubject mineExamSubject = (MineExamSubject)rxBaseData;
            List<SubjectItem> items = mapReuslt.get(mineExamSubject.getCode());
            if(EmptyChecker.isEmpty(items)){
                continue;
            }
            if(SUCCESS.equals(items.get(0).getResult()) ){
                mineExamSubject.setSuccessCount(mineExamSubject.getSuccessCount() + 1);
            }else {
                mineExamSubject.setFailCount(mineExamSubject.getFailCount() + 1);
            }
            Integer append = mineExamSubject.getFailCount() + mineExamSubject.getSuccessCount();
            if(append > 0){
                mineExamSubject.setSuccessRate(mineExamSubject.getSuccessCount()*10000/append);
            }
            // 答对率一道题，记录该题答对率。
            if(minRate > mineExamSubject.getSuccessRate() && SUCCESS.equals(items.get(0).getResult())){
                minRate = mineExamSubject.getSuccessRate();
            }

        }
        MineExamSubject updateSubject = (MineExamSubject) MineExamSubject.create(MineExamSubject.class, HANDLER_TYPE.SINGLE_BATCH_UPDATE);
        subject.getHandlerController().onlyDefault();
        updateSubject.setDataList(list);
        Object result = standardService.batchSave(updateSubject);

        if(minRate < appLogin.getMaxDifficult()){
            appLogin.setMaxDifficult(minRate);
            mineAccuScores.setMaxDifficult(minRate);
        }

        mineAccuScores.getHandlerController().onlyDefault();
        Object object = standardService.update(mineAccuScores);

        appLogin.setSuccessCount(mineAccuScores.getSuccessCount());
        appLogin.setFailCount(mineAccuScores.getFailCount());
        appLogin.setVer(appLogin.getVer() + 1);
        cacheService.putData(appLogin.getToken(),appLogin);


        return result;
    }

    @Transactional
    public Object search(AppRecordVo appLoginVo) throws IllegalAccessException, InstantiationException {

        RxUtil.CheckUtil.check(appLoginVo.getToken(), RESULT_CODE.MESSAGE, "未登录");

        AppLoginVo appLogin = (AppLoginVo)cacheService.getData(appLoginVo.getToken());
        if(EmptyChecker.isEmpty(appLogin)){
            RxUtil.CheckUtil.throwOut(RESULT_CODE.LOGIN_ERR,"未登录");
        }

        MineExamSubject subject = (MineExamSubject) MineExamSubject.create(MineExamSubject.class, HANDLER_TYPE.SINGLE_PAGE);
        subject.getHandlerController().onlyDefault();
        subject.setPageNum(appLoginVo.getPageNum());
        subject.setPageSize(appLoginVo.getPageSize());
        subject.setClasses(appLoginVo.getClasses());
        RxUtil.SQL.desc(subject, MineExamSubject.SUCCESS_RATE);

        // id > 11;
        subject.getCondition().put("gtId",15);

        List<RxBaseData> list = RxUtil.result(standardService.searchPage(subject));
        return list;
    }

    @Autowired
    MineBattleInfoMapper mapper;

    private void battlePoint(BattleVo battleVo,String loginType){
        String token = (String)cacheService.getData(battleVo.getBattleOpenId());
        if(EmptyChecker.notEmpty(token)){
            AppLoginVo appLogin = (AppLoginVo)cacheService.getData(token);
            if(EmptyChecker.notEmpty(appLogin)){
                AppLoginVo appLoginVo = new AppLoginVo();
                appLoginVo.setToken(appLogin.getToken());
                appLoginVo.setPoint(-1);
                try {
                    consume(appLoginVo);
                    return;
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                } catch (InstantiationException e) {
                    e.printStackTrace();
                }
            }
        }

        // 直接更新。
        mapper.updatePoint(1,loginType + battleVo.getBattleOpenId());

    }

    @Transactional
    public Object battle(@RequestBody BattleVo battleVo) throws IllegalAccessException, InstantiationException {

        RxUtil.CheckUtil.check(battleVo.getToken(), RESULT_CODE.MESSAGE, "未登录");
        AppLoginVo appLogin = (AppLoginVo)cacheService.getData(battleVo.getToken());
        if(EmptyChecker.isEmpty(appLogin)){
            RxUtil.CheckUtil.throwOut(RESULT_CODE.LOGIN_ERR,"未登录");
        }

        Integer point = -1;
        if(battleVo.getDiff() < 0){
            // 挑战失败。对手加积分。自己扣分
            point = 1;
            battlePoint(battleVo,appLogin.getLoginType());
        }


        MineBattleInfo mineBattleInfo = (MineBattleInfo) MineBattleInfo.create(MineBattleInfo.class,HANDLER_TYPE.SINGLE_INSERT);

        mineBattleInfo.setStatus(RX_STATUS.NORMAL.getCode());
        mineBattleInfo.getHandlerController().onlyDefault();
        RxUtil.copyProperties(battleVo,mineBattleInfo);
        mineBattleInfo.setOpenId(appLogin.getOpenId());
        mineBattleInfo.setName(appLogin.getNickName());

        AppLoginVo appLoginVo = new AppLoginVo();
        appLoginVo.setToken(appLogin.getToken());
        appLoginVo.setPoint(point);
        consume(appLoginVo);

        return standardService.insert(mineBattleInfo);

    }

    private List<BattleSearchItem> battleSearchItem(List<MineBattleInfo> scroesList){
        List<BattleSearchItem> scroesItemList = new ArrayList<>();
        for (MineBattleInfo accuScores : scroesList) {

            BattleSearchItem item = new BattleSearchItem();
            RxUtil.copyProperties(accuScores,item);
            scroesItemList.add(item);
        }
        return scroesItemList;
    }

    @Transactional
    public Object battleSearch(@RequestBody BattleVo battleVo) throws IllegalAccessException, InstantiationException {

        RxUtil.CheckUtil.check(battleVo.getToken(), RESULT_CODE.MESSAGE, "未登录");
        AppLoginVo appLogin = (AppLoginVo) cacheService.getData(battleVo.getToken());
        if (EmptyChecker.isEmpty(appLogin)) {
            RxUtil.CheckUtil.throwOut(RESULT_CODE.LOGIN_ERR, "未登录");
        }

        MineAccuScores mineAccuScores = (MineAccuScores) MineAccuScores.create(MineAccuScores.class,HANDLER_TYPE.SINGLE_PAGE);
        mineAccuScores.setPageNum(1);
        mineAccuScores.setPageSize(10);
        RxUtil.SQL.asc(mineAccuScores,"maxDifficult");


        Object result = standardService.searchPage(mineAccuScores);
        List<MineAccuScores> scroesList = RxUtil.result(result);


        MineBattleInfo mineBattleInfo = (MineBattleInfo)MineBattleInfo.create(MineBattleInfo.class,HANDLER_TYPE.SINGLE_PAGE);
        mineBattleInfo.setPageNum(1);
        mineBattleInfo.setPageSize(20);
        RxUtil.SQL.desc(mineBattleInfo,"id");
        Object resultBattle = standardService.searchPage(mineBattleInfo);
        List<MineBattleInfo> resultBattleList = RxUtil.result(resultBattle);


        MineBattleInfo myBattleInfo = (MineBattleInfo)MineBattleInfo.create(MineBattleInfo.class,HANDLER_TYPE.SINGLE_PAGE);
        myBattleInfo.setPageNum(1);
        myBattleInfo.setPageSize(10);
        myBattleInfo.setOpenId(appLogin.getOpenId());
        RxUtil.SQL.desc(myBattleInfo,"id");

        Object myBattle = standardService.searchPage(myBattleInfo);
        List<MineBattleInfo> myBattleList = RxUtil.result(myBattle);


        MineBattleInfo mimeBattleInfo = (MineBattleInfo)MineBattleInfo.create(MineBattleInfo.class,HANDLER_TYPE.SINGLE_PAGE);
        mimeBattleInfo.setPageNum(1);
        mimeBattleInfo.setPageSize(10);
        mimeBattleInfo.setBattleOpenId(appLogin.getOpenId());
        RxUtil.SQL.desc(mimeBattleInfo,"id");

        Object mineBattle = standardService.searchPage(mimeBattleInfo);
        List<MineBattleInfo> mimeBattleList = RxUtil.result(mineBattle);

        BattleSearchVo battleSearchVo = new BattleSearchVo();

        List<BattleSearchItem> scroesItemList = new ArrayList<>();
        for (MineAccuScores accuScores : scroesList) {
            BattleSearchItem item = new BattleSearchItem();
            RxUtil.copyProperties(accuScores,item);
            scroesItemList.add(item);
        }
        battleSearchVo.setScoresList(scroesItemList);
        battleSearchVo.setBattleList(battleSearchItem(resultBattleList));
        battleSearchVo.setMyList(battleSearchItem(myBattleList));   // 我接受的挑战
        battleSearchVo.setToList(battleSearchItem(mimeBattleList)); // 我发起的挑战

        return battleSearchVo;
    }
}
